/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.jdbc.dao;

import com.thienloc.omap.jdbc.entity.TblSmsBroadcasting;
import com.thienloc.omap.util.DBUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author GiangLT
 */
public class TblTmpDao extends BaseDao {

    public int add(TblSmsBroadcasting item) throws SQLException {
        int result = 0;
        Connection con = DBUtil.getConnection(TL_JNDI);
        if (con == null) {
            return result;
        }
        if (item == null) {
            return 0;
        }
        PreparedStatement ps = null;
        try {
            String cmd = "INSERT INTO TBL_TMP(sc, msisdn, sms, provider, result, sent_time)"
                    + " VALUES(?,?,?,?,?,?)";
            ps = con.prepareStatement(cmd);
            ps.setString(1, item.getSc());
            ps.setString(2, item.getMsisdn());
            ps.setString(3, item.getSms());
            ps.setString(4, item.getProvider());
            ps.setString(5, item.getResult());
            ps.setString(6, item.getSentTime());
            result = ps.executeUpdate();
            DbAccess.commitTransaction(con);
        } finally {
            DbAccess.closePreparedStatement(ps);
            DbAccess.closeConnection(con);
        }
        return result;
    }
}
